<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    const testArr = [1, 2, [{name: 123}], [[1, 2, [3, 4]]], [[[5, 6, 7], [[8, 9], 10], 11], 12]] // [1,2, {name: 123}]

    let result = []

    function flap2(arr) {
        arr.forEach(item => {
            if (!Array.isArray(item)) {
                result.push(item)
            } else {
                flap2(item)
            }
        })
    }

    flap2(testArr)
    console.log(result);
</script>
</body>
</html>
